package com.bookcloud.java21.chapter4.类的构建函数45;

public class Person2 {
  // 成员变量
  private String name;
  private int age;
  private String sex;

  // 无参构造函数
  public Person2() {
    System.out.println("无参构造函数");
  }

  // 有参构造函数
  public Person2(String name, int age, String sex) {
    this.name = name;
    this.age = age;
    this.sex = sex;
    System.out.println("有3个参构造函数");
  }

  // 重载构造函数
  public Person2(String name, int age) {
    this(name, age, "未指定");
    System.out.println("有2个参重载构造函数");
  }

  // 重载构造函数
  public Person2(String name) {
    this(name, 0);
    System.out.println("有1个参重载构造函数");
  }

  public String getName() {
    return name;
  }

  public int getAge() {
    return age;
  }

  public String getSex() {
    return sex;
  }
}
